/*********************************************************************************************************
**
**                                   GJB 标准测试集
**
**                               Copyright All Rights Reserved
**
**--------------文件信息--------------------------------------------------------------------------------
**
** 文   件   名: gjb_S0100901GN_6.c
**
** 文件创建日期: 2021 年 1 月 22 日
**
** 描        述: 初始化、销毁条件变量功能测试
*********************************************************************************************************/
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>

//#include "gjb.h"

int gjb_S0100901GN_6(int argc, char **argv)
{

    pthread_cond_t cond;
    int rc;

    /*
     * Initialize cond2 with NULL attributes
     */
    if((rc=pthread_cond_init(&cond,NULL)) != 0) {
        printf("Fail to initialize cond, rc=%d\n",rc);
        goto __errno_handle;
    }

    if(pthread_cond_destroy(&cond) != 0) {
        printf("Fail to destroy cond\n");
        printf("Test FAILED\n");

        goto __errno_handle;
    }

    /*
     * Try to destroy a NULL condition variable attributes object using pthread_cond_destroy()
     * It should return EINVAL
     */
    if((rc=pthread_cond_destroy(&cond)) == EINVAL) {
        printf("Test PASSED\n");

    } else {
        printf("Test FAILED: *NOTE: Expect %d(EINVAL), but return %d.\n", EINVAL, rc);
        goto __errno_handle;
    }


    if((rc=pthread_cond_destroy(NULL)) == EINVAL)  {
        printf("Test PASSED when para is null.\n");

    } else {
        printf("Test FAILED:  when para is null.*NOTE: Expect %d(EINVAL), but return %d.\n", EINVAL, rc);
        goto __errno_handle;
    }

    printf("<RSLT>..................................................[(0)]\n \n \n");

    return  (0);

__errno_handle:
    printf("<RSLT>..................................................[(-1)]\n \n \n");
    return  (-1);
}




